package com.project.account.service;

import com.project.account.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: seata-at
 * @description: account业务类
 * @author: mml
 * @create: 2023/12/18
 */
@Service
public class AccountService {

    @Autowired
    AccountMapper accountMapper;

    public boolean deductAccount(String account, Double money) {
        accountMapper.updateAccount(account,money);
        Double money1 = accountMapper.getMoneyByAccount(account);
        if (money1 <0) {
           throw  new RuntimeException("余额不足，扣除失败");
        }
        return true;
    }
}
